cmake_minimum_required (VERSION 3.0)

project (osgShaderRef)

FIND_PATH(OPENSCENEGRAPH_INCLUDE_DIR osg/Referenced
    PATHS
    $ENV{OSG_ROOT}/include
    $ENV{OSG_DIR}/include
    /usr/include 
    /usr/local/include
)

FIND_PATH(OPENSCENEGRAPH_LIB_DIR libosg.so osg.lib
    PATHS
    $ENV{OSG_ROOT}/lib
    $ENV{OSG_DIR}/lib
    /usr/lib 
    /usr/local/lib
)

INCLUDE_DIRECTORIES(${OPENSCENEGRAPH_INCLUDE_DIR})
LINK_DIRECTORIES(${OPENSCENEGRAPH_LIB_DIR})

SET(CMAKE_DEBUG_POSTFIX  "d" CACHE STRING "add a Debug postfix, usually d on windows")


FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/media DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

MACRO(START_EXAMPLE)

    INCLUDE_DIRECTORIES(${EXTERNAL_INCLUDE_DIR})
	FILE(GLOB SHADERSRC "shader/*")
	SOURCE_GROUP(shader FILES ${SHADERSRC})
    ADD_EXECUTABLE(${EXAMPLE_NAME} ${EXAMPLE_FILES} ${SHADERSRC})
    SET_TARGET_PROPERTIES(${EXAMPLE_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
	
    TARGET_LINK_LIBRARIES(${EXAMPLE_NAME}
        debug osg${CMAKE_DEBUG_POSTFIX}          optimized osg
        debug osgAnimation${CMAKE_DEBUG_POSTFIX} optimized osgAnimation
        debug osgParticle${CMAKE_DEBUG_POSTFIX}  optimized osgParticle
        debug osgDB${CMAKE_DEBUG_POSTFIX}        optimized osgDB
        debug osgGA${CMAKE_DEBUG_POSTFIX}        optimized osgGA
        debug osgText${CMAKE_DEBUG_POSTFIX}      optimized osgText
        debug osgUtil${CMAKE_DEBUG_POSTFIX}      optimized osgUtil
        debug osgViewer${CMAKE_DEBUG_POSTFIX}    optimized osgViewer
        debug OpenThreads${CMAKE_DEBUG_POSTFIX}  optimized OpenThreads
        ${EXTERNAL_LIBRARIES}
    )

ENDMACRO(START_EXAMPLE)

ADD_SUBDIRECTORY(ch01-01)
ADD_SUBDIRECTORY(ch01-02)
ADD_SUBDIRECTORY(ch01-03)
ADD_SUBDIRECTORY(ch01-04)
ADD_SUBDIRECTORY(ch02-01)
ADD_SUBDIRECTORY(ch02-02)
ADD_SUBDIRECTORY(ch02-03)
ADD_SUBDIRECTORY(ch02-04)
ADD_SUBDIRECTORY(ch02-05)
ADD_SUBDIRECTORY(cht)
